<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="店名" prop="storeName">
        <el-input
          v-model="queryParams.storeName"
          placeholder="请输入店名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="省份" prop="storeProvince">
        <el-input
          v-model="queryParams.storeProvince"
          placeholder="请输入省份"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="开业时间" prop="openTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.openTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择开业时间">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="storeinfoList">
      <el-table-column label="序号" type="index" width="55" align="center" />
      <el-table-column prop="id" v-if="false"/>
      <el-table-column label="店名" align="center" prop="store_name" />
      <el-table-column label="省份" align="center" prop="store_province" />
      <el-table-column label="市" align="center" prop="store_city" />
      <el-table-column label="开业时间" align="center" prop="open_time"/>
      <el-table-column label="租赁期限（单位：年）" align="center" prop="lease_time" width="150"/>
      <el-table-column label="租赁面积" align="center" prop="lease_area" />
      <el-table-column label="总收入（单位：万）" align="center" prop="zsr" />
      <el-table-column label="总支出（单位：万）" align="center" prop="zzc" />
      <el-table-column label="总利润（单位：万）" align="center" prop="zlr" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-data"
            @click="szdetail(scope.row.id)"
          >总收支</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"/>

  </div>
</template>

<script>
  import {  storeDetailCount } from "@/api/manage/datacount";

  export default {
    name: "Storeinfo",
    components: {
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 便利蜂分店信息表格数据
        storeinfoList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          storeName: undefined,
          storeProvince: undefined,
          openTime: undefined
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询便利蜂分店信息列表 */
      getList() {
        this.loading = true;
        storeDetailCount(this.queryParams).then(response => {
          this.storeinfoList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          storeName: undefined,
          storeProvince: undefined,
          openTime: undefined,
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },

      szdetail(id){
        this.$router.push({ path: '/storeincome/incomecount', query: { id: id } })
      },

    }
  };
</script>
